unit KomisyonHesapla;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, XPMan, StdActns, ActnList, wwdblook, StdCtrls, Mask,
  wwdbedit, DB, ADODB, Buttons;

type
  TfmKomisyonHesapla = class(TfmFormClass)
    Label1: TLabel;
    edYatirTutar: TwwDBEdit;
    Label2: TLabel;
    lcBanka: TwwDBLookupCombo;
    Label3: TLabel;
    edCekilecekTutar: TwwDBEdit;
    aqKomisyon: TADOQuery;
    bkapat: TBitBtn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bkapatClick(Sender: TObject);
    procedure edYatirTutarChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmKomisyonHesapla: TfmKomisyonHesapla;

implementation
uses data, Math;
{$R *.dfm}

procedure TfmKomisyonHesapla.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmKomisyonHesapla := nil;
end;

procedure TfmKomisyonHesapla.bkapatClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TfmKomisyonHesapla.edYatirTutarChange(Sender: TObject);
var
  Sonuc: Extended;
begin
  inherited;
  if (Trim(edYatirTutar.Text) = '') then
    edYatirTutar.Text := '0';

  if (Trim(edYatirTutar.Text) <> '') and (Trim(lcBanka.Text) <> '') then
  begin
    Sonuc := -1 * StrToFloat(edYatirTutar.Text) / ((aqKomisyon.FieldByName('Komisyon').AsFloat / 100) - 1);
    edCekilecekTutar.Text := FormatFloat('0.00', Sonuc);
  end
  else
    edCekilecekTutar.Text := '0';
end;

procedure TfmKomisyonHesapla.FormCreate(Sender: TObject);
begin
  inherited;
  OpenQueryOnDataSet(aqKomisyon.SQL.Text, aqKomisyon);
end;

end.

